const app = getApp();
Component({
  data: {
    active:'0',
    list: [{
      url:'/pages/index/index',
      text: "首页",
      name:0,
      icon:'home-o'
    }, {
      url:'/pages/logs/logs',
      text: "日志",
      name:1,
      icon:'search'
    }],
    vipList: [{
      url:'/pages/index/index',
      text: "首页",
      name:0,
      icon:'home-o'
    }, {
      url:'/pages/logs/logs',
      text: "日志",
      name:1,
      icon:'search'
    },{
      url:'/pages/vip/vip',
      text: "VIP",
      name:2,
      icon:'friends-o'
    }],
    noVipList: [{
      url:'/pages/index/index',
      text: "首页",
      name:0,
      icon:'home-o'
    }, {
      url:'/pages/logs/logs',
      text: "日志",
      name:1,
      icon:'search'
    }]
  },
  attached() {
  },
  methods: {
    init() {
      const page = getCurrentPages().pop();
			this.setData({
				active: this.data.list.findIndex(item => item.url === `/${page.route}`)
			});
    },
    checkPermission() {
      if (app.globalData.userRank == 0) {
        console.log(app.globalData.userRank)
        this.setData({
					list: this.data.noVipList,
        })
      }
      if (app.globalData.userRank == 1) {
        console.log(app.globalData.userRank)
        this.setData({
					list: this.data.vipList,
        })
			}
    },
    onChange(event) {
      console.log(event)
      this.setData({ active: event.detail });
      wx.switchTab({
				url: this.data.list[event.detail].url
			});
    },
  }
})


